package com.chixing.day10_hashcode_exception;

import java.util.Objects;

public class StudentTest {
    public static void main(String[] args) {

        Student stu1 = new Student(101, "smith", "计算机", 13991838585L);
        Student stu2 = new Student(101, "smith", "计算机", 13991838585L);
        System.out.println(stu1 == stu2); // false  == 比较内存地址

        System.out.println(stu1.equals(stu2));// false 比较内容

        System.out.println((int) ('x' + 'r')); // 234  xr != yq, f(xr) = f(yq) 冲突
        System.out.println((int) ('y' + 'q')); // 234

        // 通过哈希函数得到的一个值
        System.out.println("hello".hashCode()); //99162322
        System.out.println("hellp".hashCode()); //99162323
        System.out.println("helma".hashCode()); //99162339



        Student s1 = new Student(101, "allen", "数学", 1399144444L);  // hashcode= 516180939
        Student s2 = new Student(104, "katy", "英语", 1399122222L);   // hashcode=297050053
        Student s3 = new Student(190, "smith", "计算机", 13991838585L);  // hashcode= 118544347
        Student s4 = new Student(190, "smith", "计算机", 13991838585L);  // hashcode= 118544347

        Student s5 = new Student(106, "katy", "计算机", 13991839999L);   // hashcode= 1067704969
        Student s6 = new Student(117, "walter", "英语", 13991222222L);   // hashcode= 1067704969

        System.out.println(s1.hashCode());  //115892948
        System.out.println(s2.hashCode());  //115892948
        System.out.println(s3.hashCode());  //1067704969
        System.out.println(s4.hashCode());  //115892948
        System.out.println(s5.hashCode());  //115892948
        System.out.println(s6.hashCode());  //1067704969

    }
}